var app = getApp();

Page({
    data: {
        guanzhu: !1,
        quxiaogz: !0,
        my_activity: [],
        page: 1
    },
    onLoad: function(t) {
        wx.hideShareMenu(), app.setNavigationBarColor(this);
        var a = this;
        a.setData({
            sponsor: t.sponsor,
            rz_type: t.rz_type
        }), app.util.request({
            url: "entry/wxapp/url",
            cachetime: "0",
            success: function(t) {
                console.log("这是网址"), console.log(t), wx.setStorageSync("url", t.data), a.setData({
                    url: t.data
                });
            }
        }), a.GetSponsorInfo();
    },
    GetSponsorInfo: function(t) {
        var a = this, e = a.data.sponsor;
        console.log(e), app.util.request({
            url: "entry/wxapp/GetSponsorInfo",
            cachetime: "0",
            data: {
                name: e
            },
            success: function(t) {
                console.log(t), a.setData({
                    sponsor_info: t.data
                }), a.refresh();
            }
        });
    },
    refresh: function(t) {
        var e = this, a = e.data.sponsor_info.user_id, o = app.today(), n = e.data.my_activity, s = e.data.page;
        app.util.request({
            url: "entry/wxapp/MyActivity",
            data: {
                user_id: a,
                page: s
            },
            success: function(t) {
                if (console.log(t), 0 < t.data.length) {
                    for (var a in n = n.concat(t.data), t.data) t.data[a].end_time = app.ormatDate(t.data[a].end_time).slice(0, 16), 
                    t.data[a].start_time = app.ormatDate(t.data[a].start_time).slice(0, 16), 1 == t.data[a].is_close ? o >= t.data[a].end_time ? (t.data[a].sign_up = "已结束", 
                    t.data[a].sign_state = "sign_over") : (t.data[a].sign_up = "报名中", t.data[a].sign_state = "sign_up") : (t.data[a].sign_up = "已结束", 
                    t.data[a].sign_state = "sign_over");
                    e.setData({
                        page: s + 1,
                        my_activity: n
                    });
                } else e.setData({
                    my_activity: n
                });
            }
        });
    },
    guanzhu: function() {
        this.setData({
            guanzhu: !0,
            quxiaogz: !1
        }), wx.showToast({
            title: "已关注成功",
            icon: "success",
            duration: 2e3
        });
    },
    quxiaogz: function() {
        this.setData({
            quxiaogz: !0,
            guanzhu: !1
        }), wx.showToast({
            title: "已取消关注",
            icon: "success",
            duration: 2e3
        });
    },
    my_activity: function(t) {
        console.log(t);
        var a = t.currentTarget.dataset.id;
        wx.navigateTo({
            url: "../activeinfo/activeinfo?id=" + a
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        this.setData({
            my_activity: [],
            page: 1
        }), this.refresh(), wx.stopPullDownRefresh();
    },
    onReachBottom: function() {
        this.refresh();
    }
});